package com.example.demo;

import jakarta.servlet.http.HttpSession;
import lombok.val;
import org.springframework.web.bind.annotation.*;

@RestController
public class demo2 {
    //获取cookie
    @RequestMapping("/getCookie")
    public String getC(@CookieValue("NAME") String name){
        return "sucess"+name;
    }
    //获取session
    @RequestMapping("/r3")
    public String getS(HttpSession session){
        session.setAttribute("name","张三");
        String name = (String) session.getAttribute("name");
        return "session获取成功"+name;
    }
    //获取头文件
    @RequestMapping("/r4")
    public String getH(@RequestHeader ("User-Agent") String useragent){
        return "获取useragent："+useragent;
    }


}
